
ifeq ("$(shell whoami)", "malloy")
  CXX = clang++
else
  CXX = g++
endif

# Warnings frequently signal eventual errors:
CXXFLAGS=`sdl-config --cflags` -g -W -Wall -Weffc++ -Wextra -pedantic -O0

ifeq ("$(shell uname)", "Darwin")
  LDFLAGS =
else
  ifeq ("$(shell uname)", "Linux")
  LDFLAGS = `sdl-config --libs` -lSDL_ttf -lSDL_image -lexpat -lSDL_draw -lSDL_mixer
  endif
endif

OBJS = \
	main.o \
	controller.o \
	gamedata.o \
	parseXML.o \
	model.o \
	clock.o \
	vector2f.o \
	sprite.o \
	frame.o \
	world.o \
	ioManager.o\
	frameFactory.o\
	multiFrameFactory.o\
	multiSprite.o\
	player.o \
	sound.o \
	explosion.o \
	explodingSprite.o \
	collisionStrategy.o \
	ball.o \
	item.o \
	gui.o \
	score.o


EXEC = run

# $< refers to the first dependency
%.o: %.cpp
	$(CXX) $(CXXFLAGS) -c $< -o $@

# $@ refers to the target
$(EXEC): $(OBJS)
	$(CXX) $(CXXFLAGS) -o $@ $(OBJS) $(LDFLAGS)

main.o: main.cpp
controller.o: controller.cpp controller.h model.h
parseXML.o: parseXML.cpp parseXML.h 
gamedata.o: gamedata.cpp gamedata.h parseXML.h
model.o: controller.cpp model.h sprite.h world.h clock.h
clock.o: clock.cpp clock.h sound.h
vector2f.o: vector2f.cpp vector2f.h
sprite.o: sprite.cpp sprite.h drawable.h frame.h
frame.o: frame.cpp frame.h ioManager.h
world.o: world.cpp world.h frame.h 
ioManager.o: ioManager.cpp ioManager.h
frameFactory.o:frameFactory.cpp frameFactory.h frame.h
multiFrameFactory.o:multiFrameFactory.cpp multiFrameFactory.h frameFactory.h
multiSprite.o:multiSprite.h multiSprite.cpp sprite.h
player.o:player.h player.cpp sprite.h
sound.o:sound.cpp sound.h
explosion.o:explosion.h explosion.cpp sprite.h
explodingSprite.o:explodingSprite.h explodingSprite.cpp explosion.h
collisionStrategy.o:collisionStrategy.h collisionStrategy.cpp
ball.o:ball.h ball.cpp sprite.h sound.h
item.o:item.h item.cpp sprite.h
gui.o:gui.h gui.cpp
score.o:score.h score.cpp
clean:
	rm -rf $(OBJS)
	rm -rf $(EXEC)
